package com.binhai.springboot.org.controller;

import com.binhai.springboot.org.bean.OrgBean;
import com.binhai.springboot.org.service.OrgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;



import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/org")
public class OrgController {

    @Autowired
    private OrgService service;

    @RequestMapping("/toMain.do")
    public String toMain(){

        return "org/main";
    }

    @RequestMapping("/getAllData.do")
    @ResponseBody
    public List getAllData(){

        return service.getAllData();
    }

    @RequestMapping("/getAllTreeData.do")
    @ResponseBody
    public List getAllTreeData(){

        return service.getAllTreeData();
    }
    @RequestMapping("/selectData.do")
    @ResponseBody
    public List selectData(@RequestBody OrgBean bean){

        return service.selectData(bean.getName());
    }

    @RequestMapping("/saveData.do")
    @ResponseBody
    public Map saveData(@RequestBody OrgBean bean){

        return service.saveData(bean);
    }
    @RequestMapping("/updateData.do")
    @ResponseBody
    public Map updateData(@RequestBody OrgBean bean){

        return service.updateData(bean);
    }
    @RequestMapping("/deleteData.do")
    @ResponseBody
    public Map deleteData(@RequestBody OrgBean bean){

        return service.deleteData(bean);
    }
}
